<template>
  <div class="cart-control">
    <transition name="move">
      <div class="cart-des icon-remove_circle_outline" v-show='goods.num >0' @click.stop="desCart"></div>
    </transition>
    <div class="cart-num" v-show="goods.num>0">{{goods.num}}</div>
    <div class="cart-add icon-add_circle" @click.stop="addCart"></div>
  </div>
</template>

<script>
  import Vue from 'vue';
  export default {
    props: {
      goods: {
        type: Object,
        default () {
          return {};
        }
      }
    },
    methods: {
      addCart: function () {
        this.$emit('addGoods',this.goods.id);
      },
      desCart: function () {
        this.$emit('desCartGoods',this.goods.id);
      }
    }
  }
</script>

<style lang="less" rel="stylesheet/less">
  @import '../../common/less/variable';
  .cart-control{
    font-size: 0;
    .cart-des,.cart-num,.cart-add{
      display: inline-block;
    }
    .cart-des{
      padding: 5px;
      font-size: 20px;
      line-height: 20px;
      color: @color-theme;
      &.move-enter-active, &.move-leave-active{
        transition: all 0.4s linear;
      }
      &.move-enter,&.move-leave-to{
        opacity: 0;
        transform: translate3d(24px, 0, 0)
      }
    }

    .cart-num{
      font-size: 12px;
      line-height: 20px;
      padding: 5px 5px;
      vertical-align: top;
    }
    .cart-add{
      padding: 5px;
      font-size: 20px;
      line-height: 20px;
      color: @color-theme;
    }
  }
</style>
